<template>
	<view class="page-container">
		<up-navbar safeAreaInsetTop fixed placeholder title="结果页标题" @leftClick="pageBack"></up-navbar>
		<view class="flex-col flex-c">
			<image :src="imgBaseUrl + res.icon" class="res-icon" />
			<view class="fs-32 font-500 mt-20">{{ res.statusText }}</view>
			<view class="c-grey-86 mt-16">{{ res.desc }}</view>
			<view class="mt-40">
				<zjy-button :type="res.buttonType" width="256" @click="btnClick">{{ res.buttonText }}</zjy-button>
			</view>
		</view>
	</view>
</template>

<script setup lang="ts">
import type { CommonRes } from "@/types/common"
import { pageBack } from "@/utils/page-redirect"
import { onLoad } from "@dcloudio/uni-app"

const imgBaseUrl = inject("imgBaseUrl")
const type = ref("")
const res = ref({} as CommonRes)
const initRes = () => {
	switch (type.value) {
		case "tgyApplication-submit":
			res.value = {
				icon: "res-success.png",
				statusText: "提交成功",
				desc: "预计 1-2 个工作日审核完成，请您耐心等待。",
				buttonText: "返回",
				buttonType: "line",
			}
			break
		case "tgyApplication-initial":
			res.value = {
				icon: "res-wait.png",
				statusText: "正在审核中",
				desc: "请耐心等待审核结果",
				buttonText: "返回",
				buttonType: "line",
			}
			break
		case "tgyApplication-refused":
			res.value = {
				icon: "res-fail.png",
				statusText: "未通过",
				desc: "未通过",
				buttonText: "重新申请",
				buttonType: "normal",
			}
			break
		case "tgyApplication-close":
			res.value = {
				icon: "res-stop.png",
				statusText: "已停止招募",
				desc: "您可继续关注后续招募动态",
				buttonText: "返回",
				buttonType: "line",
			}
			break
		default:
			break
	}
}
const btnClick = () => {
	switch (type.value) {
		case "tgyApplication-close":
		case "tgyApplication-submit":
			uni.switchTab({
				url: "/pages/home/index",
			})
			break
		case "tgyApplication-initial":
			uni.navigateBack()
			break
		case "tgyApplication-refused":
			uni.redirectTo({
				url: "/pages/promotion/apply-promoter",
			})
			break
		default:
			break
	}
}
onLoad((option) => {
	type.value = option?.type
	initRes()
})
</script>
<style lang="scss" scoped>
.res-icon {
	width: 320rpx;
	height: 320rpx;
	margin-top: 260rpx;
}
</style>
